package ooday04;

public class MasterDemo {
    public static void main(String[] args) {
        /*Animal dog = new Dog("小黑",1,"黑");
        Dog dog1 = (Dog) dog;
        Swim dog2 = (Swim) dog;
        System.out.println(dog instanceof Dog);
        System.out.println(dog instanceof Swim);

        if (dog instanceof Fish){
            Fish f1 = (Fish) dog;
        }else {
            System.out.println(dog.name+"不是鱼");
        }
         */

        Animal[] animals = new Animal[3];
        animals[0] = new Dog("小黑",1,"黑");
        animals[1] = new Chick("小花",1,"花");
        animals[2] = new Fish("小金",2,"金");
        for (int i = 0;i< animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog){
                Dog dog = (Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Chick){
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }
            if (animals[i] instanceof Swim){
                Swim f = (Swim) animals[i];
                f.swim();
            }
        }




        /*Master master = new Master();
        //Animal dog = new Dog("小黑",2,"黑");
        Dog dog = new Dog("小黑",2,"黑");
        //Animal animal = dog;
        master.feed(dog);
         */
    }
}
